﻿@model IEnumerable<dynamic>
@using ThuySan.Models
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="breadcrumb bordercolor">
    <div class="breadcrumb_inner">
        <a title="volver a Inicio" href="/">Trang chủ</a><span class="navigation-pipe">&gt;</span><span
            class="navigation_page">@ViewBag.TagName</span></div>
</div>
<h1>@ViewBag.TagName</h1>
<script type="text/javascript">
    //$(document).ready(function()
    //{
    //	$('#selectPrductSort').change(function()
    //	{
    //		var requestSortProducts = '/prestashop_39704/prices-drop.php';
    //		var splitData = $(this).val().split(':');
    //		document.location.href = requestSortProducts + ((requestSortProducts.indexOf('?') &lt; 0) ? '?' : '&amp;') + 'orderby=' + splitData[0] + '&amp;orderway=' + splitData[1];
    //	});
    //});

</script>
@functions{

    private bool IsNew(DateTime? lastModified)
    {
        return (DateTime.Now - (lastModified ?? DateTime.Now)).TotalDays <= int.Parse(System.Configuration.ConfigurationManager.AppSettings["NewProductTimeSpan"]);
    }

}
<div class="product_sort">
    <form action="" id="productsSortForm">
    <label for="selectPrductSort">
        Sắp xếp theo</label>
    <select id="selectPrductSort">
        <option selected="selected" value="position:asc">--</option>
        
        <option value="name:asc">Tên: A đến Z</option>
        <option value="name:desc">Tên: Z đến A</option>
        
    </select>
    </form>
    <ul class="product_view">
        <li class="" id="product_view_grid"></li>
        <li id="product_view_list" class="current"></li>
    </ul>
</div>
<ul id="product_list" class="bordercolor grid">
    @{
        int i = 0;
        foreach (var pro in Model)
        {
            i++;
        <li class="ajax_block_product bordercolor @(i % 3 == 0 ? "product_list-3" : "") "><a title="@pro.Description"
            class="product_img_link" href="/@pro.Category/@pro.PageUrl/@(pro.ProductId).html">
            <img alt="@pro.Name" src="@Html.UploadPath("Products")140x140_@(pro.AvatarImage)"  onError="this.src='/Content/images/140x140_error.png';"></a>
            <div class="center_block">
                <div class="product_flags">
                    <span class="new">@(IsNew(pro.LastModified)
                                                ? "Mới"
                                                : "")</span> <span class="availability bordercolor">@(pro.Status ?? false
                                                                                                              ? "Còn hàng"
                                                                                                              : "Hết hàng")</span>
                </div>
                <h3>
                    <a title="@pro.Name" href="/@pro.Category/@pro.PageUrl/@(pro.ProductId).html"
                        class="product_link">@Html.Truncate((string)pro.Name, 60)</a></h3>
                <p class="product_desc">
                    <a href="/@pro.Category/@pro.PageUrl/@(pro.ProductId).html" class="product_descr">@pro.Description</a></p>
            </div>
            <div class="right_block bordercolor">
              @*  @{
                                                 if (pro.IsReduced == true)
                                                 {
                    <span class="discount">Giảm giá!</span>
                    <span class="price">@string.Format("{0:c0}", pro.PromotionalPrice)</span>
                                                 }
                                                 else
                                                 {
                    <span class="price">@string.Format("{0:c0}", pro.Price ?? 0)</span>
                                                 }
                }*@
                <a title="Ver" href="/@pro.Category/@pro.PageUrl/@(pro.ProductId).html" class="exclusive ajax_add_to_cart_button">Chi tiết</a>
            </div>
            <div class="clear">
            </div>
        </li>
        }
    }
</ul>
